#ifndef ARITHMETIC_HPP_INCLUDED
#define ARITHMETIC_HPP_INCLUDED
#include <fstream>
//#include "arithmetic.cpp"

class bit_file
{
        unsigned char bufor;    // bufor i/o
        int counter;        // aktualna pozycja indeksu
    public:
        ofstream file;       //strumien zapisu
        ifstream file2;
        int WriteBit(const int);    //zapisuje jeden bit
        int WriteBits(void *bity, const unsigned int count);
        int WriteChar(const int c);   // zapisuje jeden bajt
        int ReadBit();
        int ReadBits(void *bity, const unsigned int count);
        int ReadChar();
        bit_file(char *,bool);
        ~bit_file();
    friend class Arythmetic;
};

class Arythmetic
{
    private:
        unsigned short lower;
        unsigned short upper;
        unsigned char niedomiar;


        bit_file *bitFile;
        bool Get_probab(char *fileName);
        void Write_ramain();
        void Save_encoded();
        void Load_encoded();
        void Count_to_range(void);
        void Write_header();
        int Read_header();
        void Init_decoder();
        void Update_range(int symbol);
        unsigned short Unscale_code(void);
        int Decode_symbol(unsigned short );

    public:

        int Encode(char *inFile,char *);
        int Decode(char *dataIn, char *);
//        Arythmetic();
//        ~Arythmetic();

};
#endif // HUFFMAN_H_INCLUDED
